package top.goldenyear.porpoise.infra.storage.controller.admin;

import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.noear.solon.annotation.*;
import top.goldenyear.porpoise.common.core.model.Ret;
import top.goldenyear.porpoise.framework.web.core.controller.BaseController;
import top.goldenyear.porpoise.framework.web.core.model.query.QPage;
import top.goldenyear.porpoise.infra.storage.dto.StorageConfigDto;
import top.goldenyear.porpoise.infra.storage.model.StorageConfig;
import top.goldenyear.porpoise.infra.storage.service.StorageConfigService;


/**
 * 文件配置表 Controller 控制层
 *
 * @author airhead
 * @since 2025-04-20
 */
@Component(tag = "adminApi")
@Mapping("/infra/storage/storageConfig")
@Slf4j
public class StorageConfigAdminController extends BaseController {
  @Inject private StorageConfigService service;

  @Post
  @Mapping("create")
  public Ret create(@Body StorageConfigDto storageConfigDto) {
    return Ret.okWithData(service.createStorageConfig(storageConfigDto));
  }

  @Post
  @Put
  @Mapping("update")
  public Ret update(@Body StorageConfigDto storageConfigDto) {
    return Ret.okWithData(service.updateStorageConfig(storageConfigDto));
  }

  @Get
  @Mapping("get")
  public Ret get(@Param Integer id) {
    return Ret.okWithData(service.getStorageConfig(id));
  }

  @Post
  @Delete
  @Mapping("delete")
  public Ret delete(@Param Integer id) {
    return Ret.okWithData(service.deleteStorageConfig(id));
  }

  @Post
  @Delete
  @Mapping("batchDel")
  public Ret batchDel(@Param List<Integer> ids) {
    return Ret.okWithData(service.batchDelStorageConfig(ids));
  }

  @Get
  @Mapping("paginate")
  public Ret paginate(QPage qPage) {
    StorageConfig storageConfig = getBean(StorageConfig.class);
    return Ret.okWithData(service.paginateStorageConfig(qPage, storageConfig));
  }

  @Get
  @Mapping("list")
  public Ret list() {
    StorageConfig storageConfig = getBean(StorageConfig.class);
    return Ret.okWithData(service.listStorageConfig(storageConfig));
  }


  @Get
  @Mapping("simpleList")
  public Ret simpleList() {
    StorageConfig storageConfig = getBean(StorageConfig.class);
    return Ret.okWithData(service.simpleListStorageConfig(storageConfig));
  }
}